<?php


namespace app\controller\home;


use app\common\controller\BaseController;
use app\common\model\Store as storeModel;
use think\App;

class Store extends BaseController
{
    protected $model;

    public function __construct(App $app, storeModel $model)
    {
        parent::__construct($app);
        $this->model = $model;
    }

    /**
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * 列表
     */
    public function query()
    {
        $where = [];
        $where['delete_time'] = 0;
        $where['status'] = 1;
        $page = input('page/d', 1);
        $pageSize = input('page_size/d', 20);
        $order = ['sort' => 'DESC'];
        $fields = 'id,store_name,store_cover,phone,address,create_time';
        return $this->model->getList($where, $fields, $order, $page, $pageSize);
    }

    /**
     * @return mixed
     *
     */
    public function detail()
    {
        return $this->model->getOne($this->params);
    }

    /**
     * @return mixed
     * 我的门店
     */
    public function my()
    {
        $page = input('page/d', 1);
        $pageSize = input('page_size/d', 20);
        $order = ['sort' => 'DESC'];
        $fields = 'id,store_name,store_cover,phone,address,create_time';
        $this->params['member_id'] = $this->memberId;
        return $this->model->myStore($this->params, $fields, $order, $page, $pageSize);
    }
}